
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Hystrix/Sentinle如何实现降级， - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Hystrix/Sentinle如何实现降级， - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Hystrix的Fallback方法是如何实现服务降级的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Hystrix允许在每个服务调用命令中定义一个Fallback方法。当主逻辑执行失败或超时时，系统会自动降级到这个Fallback方法提供的备选逻辑，从而确保即使主服务不可用，系统也能提供一定程度的服务。</div>
          </div>
          <div class="card-source">来源: Hystrinx实现降级 > 1. Fallback方法</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Hystrix中的断路器（Circuit Breaker）是如何工作的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Hystrix通过断路器监控服务的状态。当服务的失败率达到设定的阈值时，断路器会打开，此时Hystrix会快速失败而不是等待超时，以避免资源浪费。当服务恢复正常后，断路器会逐渐关闭，重新允许请求。</div>
          </div>
          <div class="card-source">来源: Hystrinx实现降级 > 2. 断路器（Circuit Breaker）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Hystrix的请求缓存功能有什么作用，它如何提高系统性能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Hystrix的请求缓存功能可以避免重复执行相同的请求。当缓存命中时，Hystrix会直接返回缓存的结果而不执行主逻辑，这样可以减轻服务压力，并提高系统的响应速度。</div>
          </div>
          <div class="card-source">来源: Hystrinx实现降级 > 3. 请求缓存</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Hystrix是如何利用并发限制来保护系统的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Hystrix支持设置并发限制。当并发请求数量达到设定的阈值时，Hystrix会拒绝新的请求并执行降级操作，从而保护系统免受过载的影响。</div>
          </div>
          <div class="card-source">来源: Hystrinx实现降级 > 5. 并发限制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Sentinel实现降级主要依赖哪几种策略？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Sentinel实现降级主要依赖四种策略：基于响应时间（RT）的降级、基于异常数的降级、熔断降级和限流降级。</div>
          </div>
          <div class="card-source">来源: Sentinle实现降级</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">策略</div>
          <div class="card-question">Sentinel是如何根据响应时间（RT）进行降级的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">策略</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当服务接口的响应时间（RT）超过预设的阈值时，Sentinel会自动降级该服务，拒绝新的请求并返回预设的降级响应，以避免因服务响应过慢导致系统资源耗尽。</div>
          </div>
          <div class="card-source">来源: Sentinle实现降级 > 1. 基于RT的降级</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">策略</div>
          <div class="card-question">Sentinel的“基于异常数降级”策略是如何工作的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">策略</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当服务接口的异常数量超过预设的阈值时，Sentinel会自动触发降级操作。它会拒绝新的请求并返回预设的降级响应，目的是为了防止异常频发导致系统崩溃。</div>
          </div>
          <div class="card-source">来源: Sentinle实现降级 > 2. 基于异常数的降级</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Sentinel的熔断降级机制在什么情况下会被触发？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当服务的异常比例超过预设的阈值时，Sentinel会自动打开熔断器。在熔断器打开的状态下，Sentinel会拒绝一段时间内的所有请求并返回降级响应，以此保护系统免受异常影响。</div>
          </div>
          <div class="card-source">来源: Sentinle实现降级 > 3. 熔断降级</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">策略</div>
          <div class="card-question">Sentinel是如何通过限流来实现降级以避免服务过载的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">策略</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Sentinel可以根据服务接口的请求量进行降级。当请求量超过预设阈值时，它会自动进行限流，拒绝新的请求并返回预设的降级响应，从而避免服务过载导致系统崩溃。</div>
          </div>
          <div class="card-source">来源: Sentinle实现降级 > 4. 限流降级</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
